package intelligentcity.gui;

import intelligentcity.conf.Conf;
import intelligentcity.model.traffic.Car;
import intelligentcity.model.traffic.Traffic;

import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;

public class TrafficDrawer {

    public static void drawTraffic(Graphics2D g2d, Traffic traffic) {
        for (Integer i : traffic.getCars().keySet()) {
            try {
                drawCar(g2d, traffic.getCars().get(i));
            } catch (NullPointerException e) {

            }
        }
    }

    public static void drawCar(Graphics2D g2d, Car car) {
        int x = car.getPoint().getX();
        int y = car.getPoint().getY();        
        y -= Conf.diameterOfEllipseCar / 2;
        x -= Conf.diameterOfEllipseCar / 2;
        g2d.fill(new Ellipse2D.Double(x, y, Conf.diameterOfEllipseCar, Conf.diameterOfEllipseCar));
    }

}
